/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.panel;

import org.rails.extjs.Option;

public class TabPanel extends Panel {
	
	public static final String TAB_POSITION_TOP = "top";
	public static final String TAB_POSITION_BOTTOM = "bottom";
	
	public TabPanel() {
		super();
	}

	public TabPanel(Option configOptions) {
		super(configOptions);
	}

	public TabPanel(String id) {
		super(id,"");
	}	
	
	public void setActiveTab(Object activeTab){
		addOption("activeTab",activeTab);
	}
	
	public Object getActiveTab(){
		return getOption("activeTab");
	}
	
	public void setAnimScroll(Boolean animScroll){
		addOption("animScroll",animScroll);
	}

	public Boolean isAnimScroll(){
		return getBoolean("animScroll",true);
	}
	
	public void setAutoTabSelector(String autoTabSelector){
		addOption("autoTabSelector",autoTabSelector);
	}
	
	public String getAutoTabSelector(){
		return getString("autoTabSelector","div.x-tab");
	}
	
	public void setAutoTabs(Boolean autoTabs){
		addOption("autoTabs",autoTabs);
	}
	
	public Boolean isAutoTabs(){
		return getBoolean("autoTabs",false);
	}
	
	public String getBaseClassName(){
		return getString("baseCls","x-tab-panel");
	}
	
	public void setDeferredRender(Boolean deferredRender){
		addOption("deferredRender",deferredRender);
	}
	
	public Boolean isDeferredRender(Boolean deferredRender){
		return getBoolean("deferredRender",true);
	}
	
	public void setEnableTabScroll(Boolean enableTabScroll){
		addOption("enableTabScroll",enableTabScroll);
	}
	
	public Boolean isEnableTabScroll(){
		return getBoolean("enableTabScroll",false);
	}
	
	public void setLayoutOnTabChange(Boolean layoutOnTabChange){
		addOption("layoutOnTabChange",layoutOnTabChange);
	}
	
	public Boolean isLayoutOnTabChange(){
		return getBoolean("layoutOnTabChange",false);
	}
	
	public void setMinTabWidth(Integer minTabWidth){
		addOption("minTabWidth",minTabWidth);
	}
	
	public Integer getMinTabWidth(){
		return getInteger("minTabWidth",30);
	}
	
	public void setMonitorResize(Boolean monitorResize){
		addOption("monitorResize", monitorResize);
	}
	
	public Boolean isMonitorResize(){
		return getBoolean("monitorResize", true);
	}
	
	public void setPlain(Boolean plain){
		addOption("plain",plain);
	}
	
	public Boolean isPlain(){
		return getBoolean("plain",false);
	}
	
	public void setResizeTabs(Boolean resizeTabs){
		addOption("resizeTabs",resizeTabs);
	}
	
	public Boolean isResizeTabs(){
		return getBoolean("resizeTabs",false);
	}
	
	public void setScrollDuration(Float scrollDuration){
		addOption("scrollDuration",scrollDuration);
	}
	
	public Float getScrollDuration(){
		return getNumber("scrollDuration",0.35).floatValue();
	}
	
	public void setScrollIncrement(Integer scrollIncrement){
		addOption("scrollIncrement",scrollIncrement);
	}
	
	public Integer getScrollIncrement(){
		return getInteger("scrollIncrement",100);
	}
	
	public void setScrollRepeatInterval(Integer scrollRepeatInterval){
		addOption("scrollRepeatInterval",scrollRepeatInterval);
	}
	
	public Integer getScrollRepeatInterval(){
		return getInteger("scrollRepeatInterval",400);
	}
	
	public void setTabClassName(String tabCls){
		addOption("tabCls", tabCls);
	}
	
	public String getTabClassName(){
		return getString("tabCls", "");
	}
	
	public void setTabMargin(Integer tabMargin){
		addOption("tabMargin",tabMargin);
	}
	
	public Integer getTabMargin(){
		return getInteger("tabMargin",2);
	}
	
	public void setTabPosition(String tabPosition){
		addOption("tabPosition",tabPosition);
	}
	
	public String getTabPosition(){
		return getString("tabPosition",TAB_POSITION_TOP);
	}
	
	public void setTabWidth(Integer tabWidth){
		addOption("tabWidth",tabWidth);
	}
	
	public Integer getTabWidth(){
		return getInteger("tabWidth",120);
	}
	
	public void setWheelIncrement(Integer wheelIncrement){
		addOption("wheelIncrement",wheelIncrement);
	}
	
	public Integer getWheelIncrement(){
		return getInteger("wheelIncrement",20);
	}
	
	@Override
	public String getScript(){
		script = new StringBuffer("");
		createItems();
		script.append("new Ext.TabPanel(");
		script.append(createOptions());
		script.append(")");
		return script.toString();
	}
	
}
